import request from '@/utils/request';

/**
 * 查询所有借阅记录 (支持分页和条件查询)
 * @param {Object} params - 查询参数 (Reserve对象，包含分页和查询字段)
 * @returns {Promise}
 */
export function findAllReserves(params) {
    return request({
        url: '/dev-api/reserves/list',
        method: 'get',
        params
    });
}

/**
 * 根据ID查询预约记录
 * @param {number} id - 预约记录ID
 * @returns {Promise}
 */
export function findReserveById(id) {
    return request({
        url: `/dev-api/reserves/${id}`,
        method: 'get'
    });
}

/**
 * 新增预约记录
 * @param {Object} data - 预约记录数据 (Reserve对象)
 * @returns {Promise}
 */
export function addReserve(data) {
    return request({
        url: '/dev-api/reserves/add',
        method: 'post',
        data
    });
}

/**
 * 更新预约记录
 * @param {Object} data - 预约记录数据 (Reserve对象)
 * @returns {Promise}
 */
export function updateReserve(data) {
    return request({
        url: '/dev-api/reserves/update',
        method: 'post',
        data
    });
}

/**
 * 根据ID删除预约记录
 * @param {number} id - 预约记录ID
 * @returns {Promise}
 */
export function deleteReserve(id) {
    return request({
        url: `/dev-api/reserves/${id}`,
        method: 'delete'
    });
}

/**
 * 根据用户ID查询预约记录
 * @param {number} userId - 用户ID
 * @returns {Promise}
 */
export function findReservesByUserId(userId) {
    return request({
        url: `/dev-api/reserves/user/${userId}`,
        method: 'get'
    });
}

/**
 * 根据书籍ID查询预约记录
 * @param {number} bookId - 书籍ID
 * @returns {Promise}
 */
export function findReservesByBookId(bookId) {
    return request({
        url: `/dev-api/reserves/book/${bookId}`,
        method: 'get'
    });
}